﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using DoNet.Web.Models;
using DotNet.Log;

namespace DoNet.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly IConfiguration config;
        private IMemoryCache cache;

        public HomeController(IConfiguration config, IMemoryCache cache)
        {
            this.config = config;
            this.cache = cache;
        }

        public IActionResult Index()
        {
            try
            {
                string Name = config["AllowedHosts"];
                string Name2 = config["Logging:LogLevel:Default"];
                Convert.ToInt32("aa");
            }
            catch (Exception ex)
            {
                //_log.Error("字符串转int失败，", ex);
                Logger.Singleton.Error("字符串转int失败，", ex);
            }
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
